<!DOCTYPE html>
<html>
<head>
<title>Test Results</title>
<link type="text/css" rel="stylesheet" href="/stylesheets/testfile.css" />
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m
)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-55762617-8', {'siteSpeedSampleRate': 100});
  ga('send', 'pageview');
</script>
</head>
<body>
<h1>Test Results
{% if builder or test_type or name %}
- {{ builder }} {{test_type }} {{ name }}
{% endif %}
</h1>
<div>
    <table>
        <tr>
            <th>Master</th>
            <th>Builder</th>
            <th>Test Type</th>
            <th>Build Number</th>
            <th>File</th>
            <th>Date</th>
            {% if admin %}
            <th></th>
            {% endif %}
        {% for file in files %}
        <tr>{% if file.builder and file.name %}
            <td><a href="/testfile?master={{ file.master }}" >
                {{ file.master }}
                </a>
            </td>
            <td><a href="/testfile?builder={{ file.builder }}" >
                {{ file.builder }}
                </a>
            </td>
            <td>{% if file.test_type %}
                <a href="/testfile?testtype={{ file.test_type }}" >
                {{ file.test_type }}
                </a>
                {% endif %}
            </td>
            <td>
                <a href="/testfile?buildnumber={{ file.build_number }}" >
                {{ file.build_number }}
                </a>
            </td>
            <td><a href="/testfile?builder={{ file.builder }}&name={{ file.name }}&master={{ file.master }}&testtype={{ file.test_type }}&buildnumber={{ file.build_number }}" >
                {{ file.name }}
                </a>
            </td>
            <td>
                <script>
                    // This date format needs to match the format string used in model/testfile.py:get_files.
                    var beforeQueryParameter = 'before={{ file.date|date:"Y-m-d\TH:i:s" }}Z';
                    var url = location.toString();
                    if (url.indexOf('before') == -1)
                        url += (url.indexOf('?') == -1 ? '?' : '&') + beforeQueryParameter;
                    else
                        url = url.replace(/before=[^&]*/, beforeQueryParameter);
                    document.write('<a href="' + url + '">' + new Date('{{ file.date|date:"c" }}').toLocaleString() + '</a>')
                </script>
            </td>
            {% if admin %}
            <td><a href="/testfile/delete?key={{ file.key }}&builder={{ builder }}&name={{ name }}" >
                Delete
                </a>
            </td>
            {% endif %}
        {% endif %}
        </tr>
    {% endfor %}
    </table>
</div>
</body>
</html>
